<ion-header>
    <ion-toolbar>
        <ion-buttons slot="start">
            <ion-back-button [text]="'core.back' | translate" />
        </ion-buttons>
        <ion-title>
            <h1>
                <core-format-text [text]="title" [contextLevel]="contextLevel" [contextInstanceId]="contextInstanceId" />
            </h1>
        </ion-title>
    </ion-toolbar>
</ion-header>
<ion-content>
    <core-split-view>
        <ion-refresher slot="fixed" [disabled]="!competencies.loaded" (ionRefresh)="refreshCompetencies($event.target)">
            <ion-refresher-content pullingText="{{ 'core.pulltorefresh' | translate }}" />
        </ion-refresher>
        <core-loading [hideUntil]="competencies.loaded">
            <ion-list>
                <ion-item class="ion-text-wrap" *ngFor="let competency of competencies.items"
                    [attr.aria-label]="competency.competency.shortname" (click)="competencies.select(competency)"
                    [attr.aria-current]="competencies.getItemAriaCurrent(competency)" button [detail]="true">
                    <ion-label>
                        <p class="item-heading">
                            <core-format-text [text]="competency.competency.shortname" [contextLevel]="contextLevel"
                                [contextInstanceId]="contextInstanceId" /> <em>{{competency.competency.idnumber}}</em>
                        </p>
                    </ion-label>
                    @if (competency.usercompetency) {
                        <ion-badge slot="end" [color]="competency.usercompetency.proficiency ? 'success' : 'danger'">
                            {{ competency.usercompetency.gradename }}
                        </ion-badge>
                    }
                    @if (competency.usercompetencycourse) {
                        <ion-badge slot="end" [color]="competency.usercompetencycourse.proficiency ? 'success' : 'danger'">
                            {{ competency.usercompetencycourse.gradename }}
                        </ion-badge>
                    }
                </ion-item>
            </ion-list>
        </core-loading>
    </core-split-view>
</ion-content>
